/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-05-27
 * Time: 12:23
 */
class Solution11 {
    public int combinationSum4(int[] nums, int target) {
        int n = nums.length;

        //凑成总和为i有多少排列数
        int[] dp = new int[target+1];
        dp[0] = 1;

        for(int i = 1; i <= target; i++) {
            for(int j = 1; j <= n; j++) {
                if(i >= nums[j-1]) {
                    dp[i] += dp[i-nums[j-1]];
                }
            }
        }
        return dp[target];
    }
}
